Skip to content

chore: upgrade dotlottie-rs to v0.1.60, enable audio, harden native libs - #146

Merged
theashraf merged 6 commits into
mainfrom
chore/upgrade-dotlottie-rs-v0.1.60
Oct 28, 2026
Merged

theashraf merged 6 commits into
mainfrom
chore/upgrade-dotlottie-rs-v0.1.60

Conversation

@theashraf

Copy link
Copy Markdown
Member

Summary

Four commits, in order:

  1. Upgrade dotlottie-rs to v0.1.60 (3bb9d23 → 03cb06a, ThorVG v1.1.0 → v1.1.3). Brings bezier path slots, experimental video support, interruptible tweened transitions, fractional keyframe frames in themes/slots, and audio seek/segment sync fixes. The C API and generated header are unchanged, so no binding changes were needed. Also fixes the NDK version check in make/android.mk, which used a GNU-only sed escape and misparsed on macOS.
  2. Enable audio playback by building with the audio feature (rodio/cpal/oboe). The JNI bridge already handed the JavaVM and Context to dotlottie_init_android via dlsym, so that path now resolves. Adds setAudioVolume(Float) / audioVolume on the low-level player, drawable, both Views and the Compose controller, plus README docs.
  3. Stack protector for cargo-built C++ (Absent Stack Smashing Protection (SSP) #142). cargo invokes the NDK clang directly and bypasses ndk-build/CMake, which is where the NDK injects -fstack-protector-strong, so ThorVG and oboe had no canaries. The makefile now exports CFLAGS/CXXFLAGS with the flag. Rust code has no stack protector on stable rustc by design.
  4. Static libc++, libc++_shared.so no longer shipped (x86/libc++_shared.so and x86/libjnidispatch.so not passing mobsf security review #69). The NDK's prebuilt libc++_shared.so has no canaries and cannot be rebuilt. Only a C API crosses the library boundary, ThorVG is built with -fno-exceptions -fno-rtti, the JNI bridge uses no C++ stdlib, and the cdylib version script keeps libc++ out of the export table. libjnidispatch.so from the same issue stopped shipping with the move off JNA.

All four ABIs rebuilt from a clean target against NDK r29 (29.0.14206865), matching ndkVersion in Gradle.

Verification (per shipped libdotlottie_player.so)

ABI NEEDED exports unresolved libc++ __stack_chk_fail LOAD align net size change
arm64-v8a log, OpenSLES, dl, m, c 102 dotlottie_* 0 yes 16 KB −1,166 KB
armeabi-v7a same 102 0 yes 4 KB −846 KB
x86 same 102 0 yes 4 KB −1,077 KB
x86_64 same 102 0 yes 16 KB −1,130 KB

Net size = library growth from static libc++ (117–208 KB) minus the removed libc++_shared.so (0.9–1.4 MB). Header regenerated by cbindgen is byte-identical to the committed one. Feature strings (webp/png/jpg/ttf/expressions) and ThorVG 1.1.3 version string confirmed present.

Behaviour notes

  • setAudioVolume is clamped to 0f..1f natively; default 1f.
  • Every View/composable calls ensureAndroidInitialized. Headless use of com.dotlottie.dlplayer.DotLottiePlayer must call it once before loading an animation with audio, otherwise cpal panics on the missing JVM context. Documented in the README.
  • Default render thread count stays 0 (ThorVG renders synchronously unless threads is set).
  • Consumers that relied on this AAR providing libc++_shared.so for other native libs will need to supply their own; the pickFirsts rule was removed since there is nothing to pick.

Not verified here

No Android SDK on the build machine, so Gradle, the CMake build of libdlplayer.so with ANDROID_STL=c++_static, and the sample apps were not run. Please smoke test on a device: an animation with audio plays sound; plain animations render on View, GL View, Compose and hardware-buffer paths; an app that also bundles its own libc++_shared.so loads fine.

Closes #69. Addresses #142.

Bump deps/dotlottie-rs from 3bb9d23 (v0.1.58+21) to v0.1.60, which moves
ThorVG from v1.1.0 to v1.1.3 and brings bezier path slots, experimental
video support, interruptible tweened transitions and audio seek/segment
sync fixes. The C API and generated header are unchanged, so the JNI
bridge and Kotlin bindings need no changes.

Also fix the NDK version check in make/android.mk: it used a GNU-only
sed escape and misparsed the revision on macOS.
Build libdotlottie_player.so with the dotlottie-rs `audio` feature
(rodio/cpal/oboe) so .lottie files with audio layers play their sound.
The JNI bridge already handed the JavaVM and application Context to
dotlottie_init_android through dlsym, and every View and composable
calls ensureAndroidInitialized, so that path now resolves instead of
being a no-op.

Add setAudioVolume(Float) and audioVolume to the low-level player, the
drawable, both Views and the Compose controller, backed by two new JNI
methods over dotlottie_set_audio_volume / dotlottie_get_audio_volume.
Document the feature and the init requirement for headless use of the
low-level player.
cargo invokes the NDK clang directly, bypassing ndk-build and CMake,
which is where the NDK normally injects -fstack-protector-strong. As a
result ThorVG and oboe were compiled without stack canaries and
libdotlottie_player.so had no __stack_chk_fail reference (#142).
Export CFLAGS/CXXFLAGS with -fstack-protector-strong on every cargo
invocation so the cc crate applies it. Rust code itself has no stack
protector on stable rustc.

Rebuild all four ABIs against NDK r29 with the audio feature and the
hardening flag, and stamp version.txt with the v0.1.60 submodule
commit.
The NDK's prebuilt libc++_shared.so has no stack protector and is
flagged by security scanners (#69). It cannot be rebuilt, so remove it
from the AAR by linking libc++ statically into both native libraries.

This is safe here: only a C API crosses the boundary between
libdlplayer.so and libdotlottie_player.so, ThorVG is compiled with
-fno-exceptions -fno-rtti, the JNI bridge uses no C++ standard library,
and the Rust cdylib's version script keeps libc++ symbols out of the
export table (exports remain exactly the dotlottie_* C API).

For the cargo build, CXXSTDLIB="" stops the cc crate and the dotlottie-rs
build script from adding -lc++ (an NDK linker script for -lc++_shared),
and -lc++_static -lc++abi are appended through per-target RUSTFLAGS so
they follow every object that references them. The JNI bridge switches
to ANDROID_STL=c++_static and the libc++_shared pickFirst rule goes.

libdotlottie_player.so grows by 117-208 KB per ABI while the 0.9-1.4 MB
libc++_shared.so is dropped, a net reduction of 0.8-1.2 MB per ABI.
libjnidispatch.so from the same issue stopped shipping with the move
off JNA.
@changeset-bot

changeset-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 87e3923

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

android-actions/setup-android defaults to installing 'tools platform-tools'.
Google no longer publishes the legacy 'tools' package, so the setup step
fails before anything in the repository runs. Request platform-tools only.
@theashraf
theashraf merged commit dbe743f into main Oct 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

x86/libc++_shared.so and x86/libjnidispatch.so not passing mobsf security review

1 participant